package com.example.spring0909.section4.dao.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;
import com.example.spring0909.section4.dao.StudentInfo20Dao;
import com.example.spring0909.section4.entity.StudentInfo20;

//使用JdbcTemplate实现对持久层的操作
@Repository
public class StudentInfo20DaoImpl implements StudentInfo20Dao {

    @Autowired
    private JdbcTemplate jdbcTemplate;

    @Override
    public StudentInfo20 queryById(String id) {
        return jdbcTemplate.queryForObject("select * from student_info_20 where student_id = ?", new BeanPropertyRowMapper<>(StudentInfo20.class),id);
    }

    @Override
    public long count(StudentInfo20 studentInfo20) {
        return 0;
    }

    @Override
    public int insert(StudentInfo20 studentInfo20) {
        return 0;
    }

    @Override
    public int update(StudentInfo20 studentInfo20) {
        return 0;
    }

    @Override
    public int deleteById() {
        return 0;
    }

    @Override
    public int queryCount() {
        return jdbcTemplate.queryForObject("select count(*) from student_info_20",int.class);
    }
}
